import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import vitePluginImp from 'vite-plugin-imp'
import { resolve } from 'path'

export default defineConfig({
  plugins: [
    reactRefresh(),
    vitePluginImp({
      libList: [
        {
          libName: 'antd',
          style: (name) => `antd/es/${name}/style`,
        },
      ],
    }),
  ],
  server: {
    proxy: {
      '^/api': {
        // target: 'https://www.redloney.cn/api',
        target: 'http://localhost:8088',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '^/getqqinfo': {
        target: 'http://valine.api.ioliu.cn/getqqinfo',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/getqqinfo/, ''),
      },
      '^/map': {
        target: 'https://apis.map.qq.com/ws/location/v1/ip',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/map/, ''),
      },
      '^/avatar': {
        target: 'https://api.uomg.com/api/rand.avatar',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/avatar/, ''),
      },
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "./src/assets/styles/mixin.scss";',
      },
      less: {
        modifyVars: {
          // 此处也可设置直角、边框色、字体大小等
          'primary-color': '#333333',
          // 'link-color': '#0fbcf9;', // 链接色
          // 'success-color': '#26de81;', // 成功色
          // 'warning-color': '#faad14; ', // 警告色
          // 'error-color': '#ff3366; ', // 错误色
          'font-size-base': '14px; ', // 主字号
          'heading-color': 'rgba(0, 0, 0, 0.85); ', // 标题色
          'text-color': 'rgba(0, 0, 0, 0.65); ', // 主文本色
          'text-color-secondary': 'rgba(0, 0, 0, 0.45); ', // 次文本色
          'disabled-color': 'rgba(0, 0, 0, 0.25); ', // 失效色
          'border-radius-base': '2px; ', // 组件/浮层圆角
          'border-color-base': '#d9d9d9; ', // 边框色
          'box-shadow-base':
            '0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08),0 9px 28px 8px rgba(0, 0, 0, 0.05)', // 浮层阴影
        },
        javascriptEnabled: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': resolve(__dirname, './src'),
    },
  },
})
